package com.lidroid.xutils.bitmap.callback;
import ohos.media.image.PixelMap;
import ohos.agp.animation.Animator;
import ohos.agp.components.Image;
import com.lidroid.xutils.bitmap.core.BitmapDisplayConfig;

public class SimpleImageLoadCallBack implements ImageLoadCallBack {

    public void loadCompleted(Image imageView, PixelMap bitmap, BitmapDisplayConfig config) {
        switch (config.getAnimationType()) {
            case BitmapDisplayConfig.AnimationType.fadeIn:
                fadeInDisplay(imageView, bitmap);
                break;
            case BitmapDisplayConfig.AnimationType.userDefined:
                animationDisplay(imageView, bitmap, config.getAnimation());
                break;
            default:
                break;
        }
    }


    public void loadFailed(Image imageView, PixelMap bitmap) {
       // imageView.setImageElement(bitmap);
        imageView.setPixelMap(bitmap);
    }

//没有TransitionDrawable
    private void fadeInDisplay(Image imageView, PixelMap bitmap) {

        //未找到TransitionDrawable暂时先这么写
        imageView.setPixelMap(bitmap);
    }


    private void animationDisplay(Image imageView, PixelMap bitmap, Animator animation) {
       // animation.setStartTime(AnimationUtils.currentAnimationTimeMillis());
      //  imageView.setImageElement(bitmap);
     //   imageView.startAnimation(animation);
        //未找到对应实现方式
        imageView.setPixelMap(bitmap);
     //   animation.start();
    }

}
